package com.project.base.hdfs;

import com.project.base.common.Constants;
import com.project.base.core.hdfs.HdfsHelper;
import com.project.base.core.tables.LogDetail;
import org.apache.hadoop.fs.FSDataOutputStream;

import java.io.IOException;


public class LogDetailHdfsHelper extends HdfsHelper {

    private static final long serialVersionUID = 5446534526663484238L;
    public static final String TABLE_NAME = "LOG_DETAIL";

    @Override
    public void save(FSDataOutputStream outputStream, Object obj) {
        if (!(obj instanceof LogDetail)) {
            return;
        }
        LogDetail entity = (LogDetail) obj;
        String entityStr = entity.toLogStr(Constants.SEPERATOR);
        try {
            outputStream.writeUTF(entityStr);
            outputStream.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    protected String getTableName() {
        return TABLE_NAME;
    }

}
